package com.cskaoyan.dbutils.rsh;

import com.cskaoyan.connectionpool.opensource.DruidUtils;
import com.cskaoyan.dbutils.User;
import org.apache.commons.dbutils.QueryRunner;
import org.apache.commons.dbutils.handlers.BeanHandler;

import java.sql.SQLException;

/**
 * 创建日期: 2022/08/29 11:02
 *
 * @author ciggar
 */
public class BeanHandlerDemo {

    public static void main(String[] args) throws SQLException {

        // 1. 构建QueryRunner
        QueryRunner queryRunner = new QueryRunner(DruidUtils.getDataSource());

        // 2. 执行查询语句
        User user = queryRunner.query("select id,username as name,password,nickname as xxxname from user where id = ?",new BeanHandler<>(User.class),1002);


        // 3. 打印对象
        System.out.println(user);

    }
}
